<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('初始多表格')" />
    <style>
        .table-striped {
            min-height: 1%;
        }
        .container-div {
            padding: 0px 28px;
            height: auto;
        }
    </style>
</head>
<body class="gray-bg">

<input id="constractId" name="constractId" class="hidden" th:value="${constractId}">


<div class="container-div">
    <h2>总院情况</h2>
    <div class="row">
        <div class="col-xs-12 select-table table-striped">
            <table id="bootstrap-table2"></table>
        </div>
    </div>
</div>

<div class="container-div">
    <h2>分院情况</h2>
    <div class="row">
        <div class="col-xs-12 select-table table-striped">
            <table id="bootstrap-table3"></table>
        </div>
    </div>
</div>

<div class="container-div">
    <h2>采购情况</h2>
    <div class="row">
        <div class="col-xs-12 select-table table-striped">
            <table id="bootstrap-table4"></table>
        </div>
    </div>
</div>

<div class="container-div">
    <h2>到款情况</h2>
    <div class="row">
        <div class="col-xs-12 select-table table-striped">
            <table id="bootstrap-table5"></table>
        </div>
    </div>
</div>

<div class="container-div">
    <h2>人员情况</h2>
    <div class="row">
        <div class="col-xs-12 select-table table-striped">
            <table id="bootstrap-table6"></table>
        </div>
    </div>
</div>

<div th:include="include :: footer"></div>
<script th:inline="javascript">
    var prefix = ctx + "demo/operate";
    var datas = [[${@dict.getType('sys_normal_disable')}]];
    var typeDatas = [[${@dict.getType('sys_type_type')}]];
    var progressTypeDatas = [[${@dict.getType('sys_project_status')}]];
    var zyprefix = ctx + "system/institute";
    var id = $("#constractId").val();
   //总院情况
    $(function() {
        var options = {
            id: "bootstrap-table2",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            url: zyprefix + "/details/"+id,
            modalName: "总院信息",
            columns: [
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'entrustTime',
                    title: '委托时间',
                    width:  85
                },
                {
                    field: 'entrustName',
                    title: '委托单位'
                },
                {
                    field: 'type',
                    title: '类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'content',
                    title: '工作内容'
                },
                {
                    field: 'progressType',
                    title: '合同进度',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(progressTypeDatas, value);
                    }
                },
                {
                    field: 'money',
                    title: '合同额',
                    formatter: function(value, row, index) {
                        return row.money.toFixed(4);
                    }
                },
                {
                    field: 'payMoney',
                    title: '已支付金额',
                    formatter: function(value, row, index) {
                        return row.payMoney.toFixed(4);
                    }
                },
                {
                    field: 'payDiv',
                    title: '已经支付比例',
                    formatter:function (value, row, index) {
                        return ((row.payMoney/row.money)*100).toFixed(0) + '%';
                    }
                },
                {
                    field: 'pendingPay',
                    title: '待支付金额',
                    formatter:function (value, row, index) {
                        //总院的合同额 * 到款比例 -总院的已支付金额
                        return  (row.pendingPay * (row.remindPay/row.pendingPay) - row.payMoney).toFixed(4)
                    }
                }]
        };
        $.table.init(options);
    });

    //分院情况
    var fyprefix = ctx + "system/branch";
    var progressDatas = [[${@dict.getType('sys_total_progress')}]];
    $(function() {
        var options = {
            url: fyprefix + "/details/"+id,
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            id: "bootstrap-table3",
            modalName: "分院信息",
            columns: [
                {
                    field: 'id',
                    title: '主键',
                    visible: false
                },
                {
                    field: 'entrustTime',
                    title: '委托时间',
                    width:  85
                },
                {
                    field: 'entrustName',
                    title: '委托单位'
                },
                {
                    field: 'content',
                    title: '工作内容'
                },
                {
                    field: 'progress',
                    title: '合同进度',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(progressDatas, value);
                    }
                },
                {
                    field: 'money',
                    title: '合同额',
                    formatter: function(value, row, index) {
                        return row.money.toFixed(4);
                    }
                },
                {
                    field: 'payMoney',
                    title: '已支付金额',
                    formatter: function(value, row, index) {
                        return row.payMoney.toFixed(4);
                    }
                },
                {
                    field: 'invoiceMoney',
                    title: '已开票金额',
                    formatter: function(value, row, index) {
                        return row.invoiceMoney.toFixed(4);
                    }
                },
                {
                    field: 'pendingMoney',
                    title: '待支付金额',
                    formatter:function (value, row, index) {
                        return (row.invoiceMoney-row.payMoney).toFixed(4);
                    }
                },
                {
                    field: 'remindMoney',
                    title: '剩余合同款项'  ,
                    formatter:function (value, row, index) {
                        return (row.money-row.invoiceMoney).toFixed(4);
                    }
                }]
        };
        $.table.init(options);
    });


//采购情况
    var cgprefix = ctx + "system/purchase";
    var supplierDatas = [[${@dict.getType('tmp_ss')}]];
    var statusDatas = [[${@dict.getType('sys_supplier_status')}]];
    $(function() {
        var options = {
            url: cgprefix + "/details/"+id,
            id: "bootstrap-table4",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "采购明细",
            columns: [
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'name',
                    title: '项目名称'
                },
                {
                    field: 'supplier',
                    title: '供应商'
                },
                {
                    field: 'money',
                    title: '合同额',
                    formatter: function(value, row, index) {
                        return row.money.toFixed(4);
                    }
                },
                {
                    field: 'payMoney',
                    title: '已支付额',
                    formatter: function(value, row, index) {
                        return row.payMoney.toFixed(4);
                    }
                },
                {
                    field: 'status',
                    title: '状态',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(statusDatas, value);
                    }
                },
                {
                    field: 'signTime',
                    title: '签订时间',
                    width:  85
                },
                {
                    field: 'signupTime',
                    title: '登记时间',
                    width:  85
                },
                {
                    field: 'type',
                    title: '分类'
                }]
        };
        $.table.init(options);
    });


//到款情况
    var dkprefix = ctx + "system/record";

    $(function() {
        var options = {
            url: dkprefix + "/details/"+id,
            id: "bootstrap-table5",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "到款信息",
            columns: [
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'toTime',
                    title: '到款时间',
                    width:  85
                },
                {
                    field: 'signTime',
                    title: '登记时间',
                    width:  85
                },
                {
                    field: 'followUp',
                    title: '跟进人',
                    width:  100
                },
                {
                    field: 'money',
                    title: '到款金额',
                    formatter: function(value, row, index) {
                        return row.money.toFixed(4);
                    }
                },
                {
                    field: 'remark',
                    title: '到款依据'
                },
                {
                    field: 'culType',
                    title: '计算方法'
                }]
        };
        $.table.init(options);
    });

//人员情况
    var typeDatas = [[${@dict.getType('sys_staff_type')}]];
    var ryprefix = ctx + "system/staff";

    $(function() {
        var options = {
            url: ryprefix + "/details/"+id,
            id: "bootstrap-table6",
            sortName: "type",
            sortOrder: "asc",
            showSearch: false,
            showRefresh: false,
            showToggle: false,
            showColumns: false,
            modalName: "合同人员",
            columns: [
                {
                    field: 'id',
                    title: '',
                    visible: false
                },
                {
                    field: 'type',
                    title: '人员类型',
                    formatter: function(value, row, index) {
                        return $.table.selectDictLabel(typeDatas, value);
                    }
                },
                {
                    field: 'post',
                    title: '岗位'
                },
                {
                    field: 'major',
                    title: '专业'
                },
                {
                    field: 'name',
                    title: '姓名',
                    width:  85
                },
                {
                    field: 'title',
                    title: '职称'
                }]
        };
        $.table.init(options);
    });



</script>
</body>
</html>